<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/resources/template/template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:pe="http://primefaces.org/ui/extensions"
                xmlns:au="http://java.sun.com/jsf/composite/autocomplete">

    <ui:define name="content">
        <h:form>
            <p:panel header="Leave Application Form">


                <p:panel header="Search Leave Forms" >
                    <p:panel>
                        <p:panelGrid columns="2" >
                            <h:outputLabel value="From Date"/>
                            <p:calendar value="#{staffLeaveApplicationFormController.fromDate}"
                                        pattern="dd MMMM yyyy">     
                            </p:calendar>   
                            <h:outputLabel value="To Date"/>
                            <p:calendar value="#{staffLeaveApplicationFormController.toDate}"
                                        pattern="dd MMMM yyyy">
                            </p:calendar> 
                            <h:outputLabel value="Staff : "/>
                            <au:completeStaff value="#{staffLeaveApplicationFormController.staff}"/>                               
                            <h:outputLabel value="Leave Type"/>
                            <p:selectOneMenu  value="#{staffLeaveApplicationFormController.leaveType}">
                                <f:selectItem itemLabel="Select Day Type"/>
                                <f:selectItems value="#{enumController.leaveType}"/>
                            </p:selectOneMenu> 
                            <h:outputLabel value="With Out Cancel"/>
                            <p:selectBooleanCheckbox value="#{staffLeaveApplicationFormController.withOutretRierd}"
                                                     itemLabel="With Out Cancel"/>
                            <h:outputLabel value="Leave Approved Person"/>
                            <au:completeStaff value="#{staffLeaveApplicationFormController.approvedStaff}"/>                             
                            <p:commandButton value="Search Created Date" ajax="false" action="#{staffLeaveApplicationFormController.createleaveTable()}" />
                            <p:commandButton value="Search Approved Date" ajax="false" action="#{staffLeaveApplicationFormController.createleaveTableApprovedDate()}" />
                            <p:commandButton value="Search Shift Date" ajax="false" action="#{staffLeaveApplicationFormController.createleaveTableShiftDate()}" />
                            <p:commandButton ajax="false" value="Excel" styleClass="noPrintButton" onclick="onSubmitButton();" >
                                <pe:exporter type="xlsx" target="tb1" fileName="hr_form_staff_leave_report"  />
                            </p:commandButton>
                            <p:commandButton value="Print" ajax="false" action="#" >
                                <p:printer target="gpBillPreview" ></p:printer>
                            </p:commandButton>
                        </p:panelGrid>
                    </p:panel>
                    <p:panel id="gpBillPreview" styleClass="noBorder summeryBorder" > 
                        <p:dataTable  value="#{staffLeaveApplicationFormController.leaveForms}" var="l" 
                                      rowStyleClass="#{l.retired eq true ? 'redText':''}" id="tb1">

                            <f:facet name="header">
                                <h:outputLabel value="#{sessionController.loggedUser.institution.name}" /><br></br>
                                <h:outputLabel value="Leave Application Form Report " /><br/>
                                <h:outputLabel value="  From : "  />
                                <h:outputLabel  value="#{staffLeaveApplicationFormController.fromDate}" >
                                    <f:convertDateTime pattern="dd MM yy "/>
                                </h:outputLabel>
                                <h:outputLabel/>
                                <h:outputLabel/>
                                <h:outputLabel value="  To : "/> 
                                <h:outputLabel  value="#{staffLeaveApplicationFormController.toDate}">
                                    <f:convertDateTime pattern="dd MM yy "/>
                                </h:outputLabel><br/>
                                <h:panelGroup rendered="#{staffLeaveApplicationFormController.reportKeyWord.staff ne null}" >
                                    <h:outputLabel value="Staff : #{staffLeaveApplicationFormController.reportKeyWord.staff.person.name}"/>
                                    <br/>
                                </h:panelGroup>

                            </f:facet>
                            <p:column headerText="Form Number" sortBy="#{l.code}">
                                <f:facet name="header">
                                    <h:outputLabel value="Form Number"/>
                                </f:facet>
                                <p:outputLabel value="#{l.code}" ></p:outputLabel>
                            </p:column>
                            <p:column headerText="Staff" >
                                <f:facet name="header">
                                    <h:outputLabel value="Staff"  />
                                </f:facet>
                                <p:outputLabel value="#{l.staff.person.nameWithTitle}" ></p:outputLabel>
                            </p:column>

                            <p:column headerText="Code" sortBy="#{l.staff.codeInterger}">
                                <f:facet name="header">
                                    <h:outputLabel value="Code"  />
                                </f:facet>
                                <p:outputLabel value="#{l.staff.codeInterger}" ></p:outputLabel>
                            </p:column>

                            <p:column headerText="Created At" sortBy="#{l.createdAt}">
                                <f:facet name="header">
                                    <h:outputLabel value="Created At"/>
                                </f:facet>
                                <p:outputLabel value="#{l.createdAt}" >
                                    <f:convertDateTime pattern="yyyy MM dd HH:mm:ss" />
                                </p:outputLabel>
                            </p:column>

                            <p:column headerText="From">
                                <f:facet name="header">
                                    <h:outputLabel value="From"  />
                                </f:facet>
                                <p:outputLabel value="#{l.fromDate}" >
                                    <f:convertDateTime pattern="yyyy MM dd HH:mm:ss" />
                                </p:outputLabel>
                            </p:column>
                            <p:column headerText="To">
                                <f:facet name="header">
                                    <h:outputLabel value="To"  />
                                </f:facet>
                                <p:outputLabel value="#{l.toDate}" >
                                    <f:convertDateTime pattern="yyyy MM dd HH:mm:ss" />
                                </p:outputLabel>
                            </p:column>

                            <p:column headerText="Leave Type">
                                <f:facet name="header">
                                    <h:outputLabel value="Leave Type"  />
                                </f:facet>
                                <p:outputLabel value="#{l.leaveType}" ></p:outputLabel>                                    
                            </p:column>

                            <p:column headerText="Shift Name">
                                <f:facet name="header">
                                    <h:outputLabel value="Shift Name"  />
                                </f:facet>
                                <p:outputLabel value="#{l.staffShift.shift.name}" ></p:outputLabel>
                            </p:column>

                            <p:column headerText="Request Date">
                                <f:facet name="header">
                                    <h:outputLabel value="Request Date"  />
                                </f:facet>
                                <p:outputLabel value="#{l.requestedDate}" >
                                    <f:convertDateTime pattern="yyyy MM dd HH:mm:ss" />
                                </p:outputLabel>
                            </p:column>

                            <p:column headerText="Aproved By">
                                <f:facet name="header">
                                    <h:outputLabel value="Aproved By"  />
                                </f:facet>
                                <p:outputLabel value="#{l.approvedStaff.person.nameWithTitle}" ></p:outputLabel>
                            </p:column>

                            <p:column headerText="Leave Approved Date">
                                <f:facet name="header">
                                    <h:outputLabel value="Leave Approved Date"  />
                                </f:facet>
                                <p:outputLabel value="#{l.approvedAt}" >
                                    <f:convertDateTime pattern="yyyy MM dd HH:mm:ss" />
                                </p:outputLabel>
                            </p:column>

                            <p:column headerText="Comment">
                                <f:facet name="header">
                                    <h:outputLabel value="Comment"  />
                                </f:facet>
                                <p:outputLabel value="#{l.comments}" ></p:outputLabel>
                            </p:column>
                            <p:column headerText="Creater">
                                <f:facet name="header">
                                    <h:outputLabel value="Creater"  />
                                </f:facet>
                                <p:outputLabel value="#{l.creater.webUserPerson.nameWithTitle}" > <br/></p:outputLabel>

                                <p:outputLabel value="Deleted By  #{l.retirer.webUserPerson.nameWithTitle}" rendered="#{l.retired}" style="color: blue;"/>
                            </p:column>
                            <f:facet name="footer">
                                <p:outputLabel value="Print By : #{sessionController.loggedUser.webUserPerson.name} - " />
                                <p:outputLabel value="Print At : " />
                                <p:outputLabel value="#{commonController.currentDateTime}" >
                                    <f:convertDateTime pattern="yyyy MMMM dd hh:mm:ss a " />
                                </p:outputLabel>
                            </f:facet>
                        </p:dataTable>
                    </p:panel> 
                </p:panel>

            </p:panel>
        </h:form>
    </ui:define> 

</ui:composition>
